<!DOCTYPE html>
<html>
	<head>
		<title>填写入住信息</title>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
		<link rel="stylesheet" href="/js/plugins/bootstrap-4.1.1-dist/css/bootstrap.min.css">
		<script src="/js/plugins/jquery/jquery.min.js"></script>
		<script src="/js/plugins/jrender/jrender.min.js"></script>
		<script src="/js/plugins/form/jquery.form.js"></script>
		<script src="/js/plugins/bootstrap-4.1.1-dist/js/bootstrap.min.js"></script>
		<link rel="stylesheet" href="/css/font/css/font-awesome.min.css" />
		<link rel="stylesheet" href="/css/reset.css" />
		<link rel="stylesheet" href="/css/myInfo.css" />
		<script src="/js/common.js"></script>
		<script src="/js/plugins/My97DatePicker/WdatePicker.js"></script>
		<script src="/js/plugins/dialog2/js/dialog.min.js"></script>
		<link rel="stylesheet" href="/js/plugins/dialog2/css/dialog.css">


		<script>
			$(function () {
                var params = getParams();
                if (params) {
                    $.get('/hotels/'+params.id,function (data) {
                        $('.info').renderValues(data);
                        $('.myBg').css('background-image','url('+data.coverUrl+')');
                    });
                }
                $('.beginDate').click(function () {
                    WdatePicker({
                        readOnly:true,
                        minDate:new Date()
                    });
                });
                $('.endDate').click(function () {
                    WdatePicker({
                        readOnly:true,
                        minDate : $('.beginDate').val()
                    });
                });
                $('#infoForm').ajaxForm(function (data) {
					if (data.success){
                        $(document).dialog({
                            type : 'confirm',
                            style: 'IOS',
                            titleShow:false,
                            content: '预订成功',
                            buttons: [
                                {
                                    name: '确定',
                                    callback: function() {
                                        window.location.href="/hotel.html";
                                    }
                                }
                            ]
                        });
					}else {
                        $(document).dialog({
                            titleShow:false,
                            content: data.msg,
                        });
					}
                });
                var user = JSON.parse(sessionStorage.getItem("user"));
                $('#commentBtn').click(function () {
					$("#infoForm input[name='user.id']").val(user.id);
					$("#infoForm input[name='hotel.id']").val(params.id);
					$('#infoForm').submit();
                });
            });
		</script>
	</head>
	<body>
		<div class="search-head">
			<div class="row nav-search">
				<div class="col">
					<a href="javascript:window.history.go(-1);">
						<span>取消</span>
					</a>
				</div>
			</div>
		</div>

		<div class="container info">
			<div class="myBg"></div>
			<div style="font-size: 20px;text-align: center">
			<p render-html="name"></p>
			</div>
			<form id="infoForm" method="post" action="/hotelForms">
					<input type="hidden" name="hotel.id" >
					<input type="hidden" name="user.id" >
					<input type="hidden" name="totalPrice" >
					<label>入&nbsp;&nbsp;住</label><input type="text" name="beginDate" class="form-control beginDate" >
					<label>退&nbsp;&nbsp;房</label><input type="text" name="endDate" class="form-control endDate" >
					<label>房间数</label><input type="number" name="roomNumber"  class="form-control" >
					<label>备&nbsp;&nbsp;注</label><textarea name="remark" class="form-control" rows="5"></textarea>
			</form>
		</div>
		<div class="operation">
			<button class="btn" id="commentBtn">预定</button>
		</div>
	</body>
</html>
